# -*- coding: utf-8 -*-
# © 2018 QYT Technology
# Authored by: Zhao Xingtao (zxt50330@gmail.com)
from flask_script import Manager, Server, Shell
from flask_migrate import Migrate, MigrateCommand

from bills import create_app
from bills.services.model import db

if __name__ == "__main__":
    app = create_app()
    manager = Manager(app)
    migrate = Migrate(app, db)
    manager.add_command('db', MigrateCommand)
    manager.add_command('runserver', Server())


    def make_shell_context():
        return dict(app=app, db=db)


    manager.add_command('shell', Shell(make_context=make_shell_context, use_ipython=True))

    @manager.command
    def hello():
        print("hello")


    manager.run()